<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"/><meta name="viewport" content="width=device-width, initial-scale=0.8"/><title>7.2&nbsp;函数的简单合约</title><link rel="stylesheet" type="text/css" href="scribble.css" title="default"/><link rel="stylesheet" type="text/css" href="racket.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-style.css" title="default"/><link rel="stylesheet" type="text/css" href="manual-racket.css" title="default"/><script type="text/javascript" src="scribble-common.js"></script><script type="text/javascript" src="manual-racket.js"></script><!--[if IE 6]><style type="text/css">.SIEHidden { overflow: hidden; }</style><![endif]--></head><body id="scribble-racket-lang-org"><div class="tocset"><div class="tocview"><div class="tocviewlist tocviewlisttopspace"><div class="tocviewtitle"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_0&quot;);">&#9658;</a></td><td></td><td><a href="index.html" class="tocviewlink" data-pltdoc="x">Racket&#25351;&#21335;</a></td></tr></table></div><div class="tocviewsublisttop" style="display: none;" id="tocview_0"><table cellspacing="0" cellpadding="0"><tr><td align="right">1&nbsp;</td><td><a href="intro.html" class="tocviewlink" data-pltdoc="x">&#27426;&#36814;&#26469;&#21040;Racket!</a></td></tr><tr><td align="right">2&nbsp;</td><td><a href="to-scheme.html" class="tocviewlink" data-pltdoc="x">Racket&#27010;&#35201;</a></td></tr><tr><td align="right">3&nbsp;</td><td><a href="datatypes.html" class="tocviewlink" data-pltdoc="x">&#20869;&#32622;&#30340;&#25968;&#25454;&#31867;&#22411;</a></td></tr><tr><td align="right">4&nbsp;</td><td><a href="scheme-forms.html" class="tocviewlink" data-pltdoc="x">&#34920;&#36798;&#24335;&#21644;&#23450;&#20041;</a></td></tr><tr><td align="right">5&nbsp;</td><td><a href="define-struct.html" class="tocviewlink" data-pltdoc="x">&#31243;&#24207;&#21592;&#23450;&#20041;&#30340;&#25968;&#25454;&#31867;&#22411;</a></td></tr><tr><td align="right">6&nbsp;</td><td><a href="modules.html" class="tocviewlink" data-pltdoc="x">&#27169;&#22359;</a></td></tr><tr><td align="right">7&nbsp;</td><td><a href="contracts.html" class="tocviewselflink" data-pltdoc="x">&#21512;&#32422;</a></td></tr><tr><td align="right">8&nbsp;</td><td><a href="i_o.html" class="tocviewlink" data-pltdoc="x">&#36755;&#20837;&#21644;&#36755;&#20986;</a></td></tr><tr><td align="right">9&nbsp;</td><td><a href="regexp.html" class="tocviewlink" data-pltdoc="x">&#27491;&#21017;&#34920;&#36798;&#24335;</a></td></tr><tr><td align="right">10&nbsp;</td><td><a href="control.html" class="tocviewlink" data-pltdoc="x">&#24322;&#24120;&#19982;&#25511;&#21046;</a></td></tr><tr><td align="right">11&nbsp;</td><td><a href="for.html" class="tocviewlink" data-pltdoc="x">&#36845;&#20195;&#21644;&#25512;&#23548;</a></td></tr><tr><td align="right">12&nbsp;</td><td><a href="match.html" class="tocviewlink" data-pltdoc="x">&#27169;&#24335;&#21305;&#37197;</a></td></tr><tr><td align="right">13&nbsp;</td><td><a href="classes.html" class="tocviewlink" data-pltdoc="x">&#31867;&#21644;&#23545;&#35937;</a></td></tr><tr><td align="right">14&nbsp;</td><td><a href="units.html" class="tocviewlink" data-pltdoc="x">&#21333;&#20803;</a></td></tr><tr><td align="right">15&nbsp;</td><td><a href="reflection.html" class="tocviewlink" data-pltdoc="x">&#21453;&#23556;&#21644;&#21160;&#24577;&#27714;&#20540;</a></td></tr><tr><td align="right">16&nbsp;</td><td><a href="macros.html" class="tocviewlink" data-pltdoc="x">&#23439;</a></td></tr><tr><td align="right">17&nbsp;</td><td><a href="languages.html" class="tocviewlink" data-pltdoc="x">&#21019;&#36896;&#35821;&#35328;</a></td></tr><tr><td align="right">18&nbsp;</td><td><a href="concurrency.html" class="tocviewlink" data-pltdoc="x">&#24182;&#21457;&#19982;&#21516;&#27493;</a></td></tr><tr><td align="right">19&nbsp;</td><td><a href="performance.html" class="tocviewlink" data-pltdoc="x">&#24615;&#33021;</a></td></tr><tr><td align="right">20&nbsp;</td><td><a href="parallelism.html" class="tocviewlink" data-pltdoc="x">&#24182;&#34892;</a></td></tr><tr><td align="right">21&nbsp;</td><td><a href="running.html" class="tocviewlink" data-pltdoc="x">&#36816;&#34892;&#21644;&#21019;&#24314;&#21487;&#25191;&#34892;&#31243;&#24207;</a></td></tr><tr><td align="right">22&nbsp;</td><td><a href="More_Libraries.html" class="tocviewlink" data-pltdoc="x">&#26356;&#22810;&#30340;&#24211;</a></td></tr><tr><td align="right">23&nbsp;</td><td><a href="dialects.html" class="tocviewlink" data-pltdoc="x">Racket&#21644;Scheme&#30340;&#26041;&#35328;</a></td></tr><tr><td align="right">24&nbsp;</td><td><a href="other-editors.html" class="tocviewlink" data-pltdoc="x">&#21629;&#20196;&#34892;&#24037;&#20855;&#21644;&#20320;&#30340;&#32534;&#36753;&#22120;&#36873;&#25321;</a></td></tr><tr><td align="right"></td><td><a href="doc-bibliography.html" class="tocviewlink" data-pltdoc="x">Bibliography</a></td></tr><tr><td align="right"></td><td><a href="doc-index.html" class="tocviewlink" data-pltdoc="x">Index</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_1&quot;);">&#9660;</a></td><td>7&nbsp;</td><td><a href="contracts.html" class="tocviewlink" data-pltdoc="x">&#21512;&#32422;</a></td></tr></table><div class="tocviewsublist" style="display: block;" id="tocview_1"><table cellspacing="0" cellpadding="0"><tr><td align="right">7.1&nbsp;</td><td><a href="contract-boundaries.html" class="tocviewlink" data-pltdoc="x">&#21512;&#32422;&#21644;&#36793;&#30028;</a></td></tr><tr><td align="right">7.2&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">&#20989;&#25968;&#30340;&#31616;&#21333;&#21512;&#32422;</a></td></tr><tr><td align="right">7.3&nbsp;</td><td><a href="contracts-general-functions.html" class="tocviewlink" data-pltdoc="x">&#19968;&#33324;&#21151;&#33021;&#21512;&#32422;</a></td></tr><tr><td align="right">7.4&nbsp;</td><td><a href="contracts-first.html" class="tocviewlink" data-pltdoc="x">&#21512;&#32422;&#65306;&#19968;&#20010;&#23436;&#25972;&#30340;&#20363;&#23376;</a></td></tr><tr><td align="right">7.5&nbsp;</td><td><a href="contracts-struct.html" class="tocviewlink" data-pltdoc="x">&#32467;&#26500;&#19978;&#30340;&#21512;&#32422;</a></td></tr><tr><td align="right">7.6&nbsp;</td><td><a href="contracts-exists.html" class="tocviewlink" data-pltdoc="x">&#29992;<span class="RktPn">#:<span class="mywbr"> &nbsp;</span>exists</span>&#21644;<span class="RktPn">#:<span class="mywbr"> &nbsp;</span>&#8707;</span>&#25277;&#35937;&#21512;&#32422;</a></td></tr><tr><td align="right">7.7&nbsp;</td><td><a href="contracts-examples.html" class="tocviewlink" data-pltdoc="x">&#38468;&#21152;&#23454;&#20363;</a></td></tr><tr><td align="right">7.8&nbsp;</td><td><a href="Building-New-Contracts.html" class="tocviewlink" data-pltdoc="x">&#24314;&#31435;&#26032;&#21512;&#32422;</a></td></tr><tr><td align="right">7.9&nbsp;</td><td><a href="contracts-gotchas.html" class="tocviewlink" data-pltdoc="x">&#38382;&#39064;</a></td></tr></table></div></div><div class="tocviewlist"><table cellspacing="0" cellpadding="0"><tr><td style="width: 1em;"><a href="javascript:void(0);" title="Expand/Collapse" class="tocviewtoggle" onclick="TocviewToggle(this,&quot;tocview_2&quot;);">&#9658;</a></td><td>7.2&nbsp;</td><td><a href="" class="tocviewselflink" data-pltdoc="x">&#20989;&#25968;&#30340;&#31616;&#21333;&#21512;&#32422;</a></td></tr></table><div class="tocviewsublistbottom" style="display: none;" id="tocview_2"><table cellspacing="0" cellpadding="0"><tr><td align="right">7.2.1&nbsp;</td><td><a href="#%28part._-_~e7~b1~bb~e5~9e~8b%29" class="tocviewlink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">-<wbr></wbr>&gt;</span></span></span>&#31867;&#22411;</a></td></tr><tr><td align="right">7.2.2&nbsp;</td><td><a href="#%28part._simple-nested%29" class="tocviewlink" data-pltdoc="x">&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">define/<span class="mywbr"> &nbsp;</span>contract</span></span></span>&#21644; <span class="RktSym"><span class="badlink"><span class="RktValLink">-<wbr></wbr>&gt;</span></span></span></a></td></tr><tr><td align="right">7.2.3&nbsp;</td><td><a href="#%28part._any-and-any~7cc%29" class="tocviewlink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span>&#21644;<span class="RktSym"><span class="badlink"><span class="RktValLink">any/<span class="mywbr"> &nbsp;</span>c</span></span></span></a></td></tr><tr><td align="right">7.2.4&nbsp;</td><td><a href="#%28part._contracts-own%29" class="tocviewlink" data-pltdoc="x">&#36816;&#36716;&#20320;&#33258;&#24049;&#30340;&#21512;&#32422;</a></td></tr><tr><td align="right">7.2.5&nbsp;</td><td><a href="#%28part._contracts-.Contracts-on-.Higher-order-.Functions%29" class="tocviewlink" data-pltdoc="x">&#39640;&#38454;&#20989;&#25968;&#30340;&#21512;&#32422;</a></td></tr><tr><td align="right">7.2.6&nbsp;</td><td><a href="#%28part._contracts-flat-named-contracts%29" class="tocviewlink" data-pltdoc="x">&#24102;&#8221;???&#8220;&#30340;&#21512;&#32422;&#20449;&#24687;</a></td></tr><tr><td align="right">7.2.7&nbsp;</td><td><a href="#%28part._contracts-dissecting-contract-errors%29" class="tocviewlink" data-pltdoc="x">&#35299;&#26512;&#19968;&#20010;&#21512;&#32422;&#38169;&#35823;&#20449;&#24687;</a></td></tr></table></div></div></div><div class="tocsub"><div class="tocsubtitle">On this page:</div><table class="tocsublist" cellspacing="0"><tr><td><span class="tocsublinknumber">7.2.1<tt>&nbsp;</tt></span><a href="#%28part._-_~e7~b1~bb~e5~9e~8b%29" class="tocsubseclink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">-<wbr></wbr>&gt;</span></span></span>&#31867;&#22411;</a></td></tr><tr><td><span class="tocsublinknumber">7.2.2<tt>&nbsp;</tt></span><a href="#%28part._simple-nested%29" class="tocsubseclink" data-pltdoc="x">&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">define/<span class="mywbr"> &nbsp;</span>contract</span></span></span>&#21644; <span class="RktSym"><span class="badlink"><span class="RktValLink">-<wbr></wbr>&gt;</span></span></span></a></td></tr><tr><td><span class="tocsublinknumber">7.2.3<tt>&nbsp;</tt></span><a href="#%28part._any-and-any~7cc%29" class="tocsubseclink" data-pltdoc="x"><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span>&#21644;<span class="RktSym"><span class="badlink"><span class="RktValLink">any/<span class="mywbr"> &nbsp;</span>c</span></span></span></a></td></tr><tr><td><span class="tocsublinknumber">7.2.4<tt>&nbsp;</tt></span><a href="#%28part._contracts-own%29" class="tocsubseclink" data-pltdoc="x">&#36816;&#36716;&#20320;&#33258;&#24049;&#30340;&#21512;&#32422;</a></td></tr><tr><td><span class="tocsublinknumber">7.2.5<tt>&nbsp;</tt></span><a href="#%28part._contracts-.Contracts-on-.Higher-order-.Functions%29" class="tocsubseclink" data-pltdoc="x">&#39640;&#38454;&#20989;&#25968;&#30340;&#21512;&#32422;</a></td></tr><tr><td><span class="tocsublinknumber">7.2.6<tt>&nbsp;</tt></span><a href="#%28part._contracts-flat-named-contracts%29" class="tocsubseclink" data-pltdoc="x">&#24102;&#8221;???&#8220;&#30340;&#21512;&#32422;&#20449;&#24687;</a></td></tr><tr><td><span class="tocsublinknumber">7.2.7<tt>&nbsp;</tt></span><a href="#%28part._contracts-dissecting-contract-errors%29" class="tocsubseclink" data-pltdoc="x">&#35299;&#26512;&#19968;&#20010;&#21512;&#32422;&#38169;&#35823;&#20449;&#24687;</a></td></tr></table></div></div><div class="maincolumn"><div class="main"><div class="navsettop"><span class="navleft"><div class="nosearchform"></div>&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<a href="contract-boundaries.html" title="backward to &quot;7.1 合约和边界&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="contracts.html" title="up to &quot;7 合约&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="contracts-general-functions.html" title="forward to &quot;7.3 一般功能合约&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div><h4>7.2<tt>&nbsp;</tt><a name="(part._contract-func)"></a>&#20989;&#25968;&#30340;&#31616;&#21333;&#21512;&#32422;</h4><p>&#19968;&#20010;&#25968;&#23398;&#20989;&#25968;&#26377;&#19968;&#20010;<a name="(tech._~e5~ae~9a~e4~b9~89~e5~9f~9f(domain))"></a><span style="font-style: italic">&#23450;&#20041;&#22495;(domain)</span>&#21644;&#19968;&#20010;<a name="(tech._~e5~80~bc~e5~9f~9f(range))"></a><span style="font-style: italic">&#20540;&#22495;(range)</span>&#12290;&#23450;&#20041;&#22495;&#34920;&#31034;&#36825;&#20010;&#20989;&#25968;&#21487;&#20197;&#20316;&#20026;&#21442;&#25968;&#25509;&#21463;&#30340;&#20540;&#30340;&#31867;&#22411;&#65292;&#20540;&#22495;&#34920;&#31034;&#23427;&#29983;&#25104;&#30340;&#20540;&#30340;&#31867;&#22411;&#12290;&#29992;&#20854;&#23450;&#20041;&#22495;&#21644;&#20540;&#22495;&#25551;&#36848;&#19968;&#20010;&#20989;&#25968;&#30340;&#24120;&#35268;&#31526;&#21495;&#26159;</p><blockquote class="SCodeFlow"><p><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">:</span><span class="hspace">&nbsp;</span><span class="RktSym">A</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">B</span></p></blockquote><p>&#36825;&#37324;<span class="RktSym">A</span>&#26159;&#36825;&#20010;&#20989;&#25968;&#30340;&#23450;&#20041;&#22495;&#65292;<span class="RktSym">B</span>&#26159;&#20540;&#22495;&#12290;</p><p>&#19968;&#20010;&#32534;&#31243;&#35821;&#35328;&#20013;&#30340;&#20989;&#25968;&#20063;&#26377;&#23450;&#20041;&#22495;&#21644;&#20540;&#22495;&#65292;&#32780;&#19968;&#20010;&#21512;&#32422;&#21487;&#20197;&#30830;&#20445;&#19968;&#20010;&#20989;&#25968;&#22312;&#20854;&#23450;&#20041;&#22495;&#20013;&#21482;&#25509;&#25910;&#20540;&#24182;&#19988;&#22312;&#20854;&#20540;&#22495;&#20013;&#21482;&#20135;&#29983;&#20540;&#12290;&#19968;&#20010;<span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span>&#20026;&#19968;&#20010;&#20989;&#25968;&#21019;&#24314;&#36825;&#26679;&#30340;&#19968;&#20010;&#21512;&#32422;&#12290;&#19968;&#20010;<span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span>&#20043;&#21518;&#30340;&#34920;&#20026;&#23450;&#20041;&#22495;&#25351;&#23450;&#23450;&#20041;&#22495;&#24182;&#19988;&#26368;&#21518;&#20026;&#20540;&#22495;&#25351;&#23450;&#19968;&#20010;&#21512;&#32422;&#12290;</p><p>&#36825;&#37324;&#26377;&#19968;&#20010;&#21487;&#20197;&#20195;&#34920;&#19968;&#20010;&#38134;&#34892;&#24080;&#25143;&#30340;&#27169;&#22359;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><font class="badlink"><span class="RktModLink"><span class="RktMod">#lang</span></span></font><span class="hspace">&nbsp;</span><font class="badlink"><span class="RktModLink"><span class="RktSym">racket</span></span></font></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">provide</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">contract-out</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">balance</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">+</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">balance</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">amount</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#36825;&#20010;&#27169;&#22359;&#36755;&#20986;&#20004;&#20010;&#20989;&#25968;&#65306;</p><ul><li><p><span class="RktSym">deposit</span>&#65292;&#23427;&#25509;&#21463;&#19968;&#20010;&#25968;&#23383;&#24182;&#36820;&#22238;&#26576;&#20010;&#26410;&#22312;&#21512;&#32422;&#20013;&#25351;&#23450;&#30340;&#20540;&#65292;</p></li><li><p><span class="RktSym">balance</span>&#65292;&#23427;&#36820;&#22238;&#25351;&#31034;&#36134;&#25143;&#24403;&#21069;&#20313;&#39069;&#30340;&#19968;&#20010;&#25968;&#20540;&#12290;</p></li></ul><p>&#24403;&#19968;&#20010;&#27169;&#22359;&#36755;&#20986;&#19968;&#20010;&#20989;&#25968;&#26102;&#65292;&#23427;&#22312;&#33258;&#24049;&#20316;&#20026;&#8220;&#26381;&#21153;&#22120;&#65288;server&#65289;&#8221;&#19982;&#8220;&#23458;&#25143;&#31471;&#65288;client&#65289;&#8221;&#30340;&#36755;&#20837;&#36825;&#20010;&#20989;&#25968;&#30340;&#27169;&#22359;&#20043;&#38388;&#24314;&#31435;&#20004;&#20010;&#36890;&#20449;&#36890;&#36947;&#12290;&#22914;&#26524;&#23458;&#25143;&#31471;&#27169;&#22359;&#35843;&#29992;&#35813;&#20989;&#25968;&#65292;&#23427;&#21457;&#36865;&#19968;&#20010;&#20540;&#36827;&#20837;&#26381;&#21153;&#22120;&#27169;&#22359;&#12290;&#30456;&#21453;&#65292;&#22914;&#26524;&#36825;&#26679;&#19968;&#20010;&#20989;&#25968;&#35843;&#29992;&#32467;&#26463;&#24182;&#19988;&#36825;&#20010;&#20989;&#25968;&#36820;&#22238;&#19968;&#20010;&#20540;&#65292;&#36825;&#20010;&#26381;&#21153;&#22120;&#27169;&#22359;&#21457;&#36865;&#19968;&#20010;&#20540;&#22238;&#21040;&#23458;&#25143;&#31471;&#27169;&#22359;&#12290;&#36825;&#31181;&#23458;&#25143;&#31471;-&#26381;&#21153;&#22120;&#21306;&#21035;&#26159;&#24456;&#37325;&#35201;&#30340;&#65292;&#22240;&#20026;&#24403;&#20986;&#29616;&#38382;&#39064;&#26102;&#65292;&#19968;&#26041;&#25110;&#21478;&#19968;&#26041;&#23558;&#34987;&#24402;&#21646;&#12290;</p><p>&#22914;&#26524;&#19968;&#20010;&#23458;&#25143;&#31471;&#27169;&#22359;&#20934;&#22791;&#24212;&#29992;<span class="RktSym">deposit</span>&#21040;<span class="RktVal">'</span><span class="RktVal">millions</span>&#65292;&#36825;&#23558;&#36829;&#21453;&#20854;&#21512;&#32422;&#12290;&#21512;&#32422;&#30417;&#35270;&#31995;&#32479;&#20250;&#33719;&#24471;&#36825;&#20010;&#36829;&#35268;&#24182;&#22240;&#20026;&#19982;&#19978;&#36848;&#27169;&#22359;&#36829;&#32972;&#21512;&#32422;&#32780;&#24402;&#21646;&#20110;&#36825;&#20010;&#23458;&#25143;&#31471;&#12290;&#30456;&#27604;&#20043;&#19979;&#65292;&#22914;&#26524;<span class="RktSym">balance</span>&#20989;&#25968;&#20934;&#22791;&#36820;&#22238;<span class="RktVal">'</span><span class="RktVal">broke</span>&#65292;&#21512;&#21516;&#30417;&#35270;&#31995;&#32479;&#23558;&#24402;&#21646;&#20110;&#26381;&#21153;&#22120;&#27169;&#22359;&#12290;</p><p>&#19968;&#20010;<span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span>&#26412;&#36523;&#19981;&#26159;&#19968;&#20010;&#21512;&#32422;&#65307;&#23427;&#26159;&#19968;&#31181;<a name="(tech._~e5~90~88~e7~ba~a6~e7~bb~84~e5~90~88~ef~bc~88contract._combinator~ef~bc~89)"></a><span style="font-style: italic">&#21512;&#32422;&#32452;&#21512;&#65288;contract combinator&#65289;</span>&#65292;&#23427;&#32467;&#21512;&#20854;&#23427;&#21512;&#32422;&#20197;&#26500;&#25104;&#19968;&#20010;&#21512;&#32422;&#12290;</p><h5>7.2.1<tt>&nbsp;</tt><a name="(part._-_~e7~b1~bb~e5~9e~8b)"></a><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span>&#31867;&#22411;</h5><p>&#22914;&#26524;&#20320;&#24050;&#32463;&#20064;&#24815;&#20102;&#25968;&#23398;&#20989;&#25968;&#65292;&#20320;&#21487;&#20197;&#36873;&#25321;&#19968;&#20010;&#21512;&#32422;&#31661;&#22836;&#20986;&#29616;&#22312;&#20989;&#25968;&#30340;&#23450;&#20041;&#22495;&#21644;&#20540;&#22495;&#20043;&#38388;&#32780;&#19981;&#26159;&#22312;&#24320;&#22836;&#12290;&#22914;&#26524;&#20320;&#24050;&#32463;&#38405;&#35835;&#36807;&#12298;<span style="font-style: italic"><a href="http://www.htdp.org">How to Design Programs</a></span>&#12299;&#65292;&#37027;&#20320;&#24050;&#32463;&#35265;&#36807;&#36825;&#20010;&#24456;&#22810;&#27425;&#20102;&#12290;&#20107;&#23454;&#19978;&#65292;&#20320;&#20063;&#35768;&#24050;&#32463;&#22312;&#20854;&#20182;&#20154;&#30340;&#20195;&#30721;&#20013;&#30475;&#21040;&#27604;&#22914;&#36825;&#20123;&#21512;&#32422;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">provide</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">contract-out</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">. </span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="RktPn"> .</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#22914;&#26524;&#19968;&#20010;Racket&#30340;S&#34920;&#36798;&#24335;&#21253;&#21547;&#22312;&#20013;&#38388;&#24102;&#19968;&#20010;&#31526;&#21495;&#30340;&#20004;&#20010;&#28857;&#65292;&#35835;&#21462;&#22120;&#37325;&#26032;&#23433;&#25490;&#36825;&#20010;S&#34920;&#36798;&#24335;&#24182;&#25918;&#32622;&#31526;&#21495;&#21040;&#21069;&#38754;&#65292;&#23601;&#22914;&#12298;<a href="Pairs-Lists-and-Racket-Syntax.html#%28part._lists-and-syntax%29" data-pltdoc="x">&#21015;&#34920;&#21644;Racket&#35821;&#27861;</a>&#12299;&#37324;&#25551;&#36848;&#30340;&#37027;&#26679;&#12290;&#22240;&#27492;&#65292;</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">. </span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="RktPn"> .</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span></p></blockquote><p>&#21482;&#26159;&#32534;&#20889;&#30340;&#21478;&#19968;&#31181;&#26041;&#24335;</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span></p></blockquote><h5>7.2.2<tt>&nbsp;</tt><a name="(part._simple-nested)"></a>&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">define/contract</span></span></span>&#21644; <span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span></h5><p>&#22312;&#12298;<a href="contract-boundaries.html#%28part._contracts-intro-nested%29" data-pltdoc="x">&#23884;&#22871;&#21512;&#32422;&#36793;&#30028;&#27979;&#35797;</a>&#12299;&#20013;&#24341;&#20837;&#30340;<span class="RktSym"><span class="badlink"><span class="RktValLink">define/contract</span></span></span>&#34920;&#20063;&#21487;&#20197;&#29992;&#26469;&#23450;&#20041;&#21512;&#32422;&#20013;&#30340;&#20989;&#25968;&#12290;&#20363;&#22914;,</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define/contract</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktSym">amount</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#23454;&#29616;&#22312;&#36825;&#37324;&#36827;&#34892;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">....</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#23427;&#29992;&#21512;&#32422;&#26356;&#26089;&#23450;&#20041;<span class="RktSym">deposit</span>&#20989;&#25968;&#12290;&#35831;&#27880;&#24847;&#65292;&#36825;&#23545;<span class="RktSym">deposit</span>&#30340;&#20351;&#29992;&#26377;&#20004;&#20010;&#28508;&#22312;&#30340;&#37325;&#35201;&#24433;&#21709;&#65306;</p><ol><li><p>&#30001;&#20110;&#21512;&#32422;&#24635;&#26159;&#22312;&#35843;&#29992;<span class="RktSym">deposit</span>&#26102;&#36827;&#34892;&#26816;&#26597;&#65292;&#21363;&#20351;&#22312;&#23450;&#20041;&#23427;&#30340;&#27169;&#22359;&#20869;&#65292;&#36825;&#20063;&#21487;&#33021;&#22686;&#21152;&#21512;&#32422;&#34987;&#26816;&#26597;&#30340;&#27425;&#25968;&#12290;&#36825;&#21487;&#33021;&#23548;&#33268;&#19968;&#20010;&#24615;&#33021;&#19979;&#38477;&#12290;&#22914;&#26524;&#20989;&#25968;&#22312;&#24490;&#29615;&#20013;&#21453;&#22797;&#35843;&#29992;&#25110;&#20351;&#29992;&#36882;&#24402;&#26102;&#23588;&#20854;&#22914;&#27492;&#12290;</p></li><li><p>&#22312;&#26576;&#20123;&#24773;&#20917;&#19979;&#65292;&#24403;&#22312;&#21516;&#19968;&#27169;&#22359;&#20013;&#34987;&#20854;&#23427;&#20195;&#30721;&#35843;&#29992;&#26102;&#65292;&#19968;&#20010;&#20989;&#25968;&#21487;&#20197;&#32534;&#20889;&#26469;&#25509;&#21463;&#19968;&#32452;&#26356;&#23485;&#26494;&#30340;&#36755;&#20837;&#12290;&#23545;&#20110;&#27492;&#31867;&#29992;&#20363;&#65292;&#36890;&#36807;<span class="RktSym"><span class="badlink"><span class="RktValLink">define/contract</span></span></span>&#24314;&#31435;&#30340;&#21512;&#32422;&#36793;&#30028;&#36807;&#20110;&#20005;&#26684;&#12290;</p></li></ol><h5>7.2.3<tt>&nbsp;</tt><a name="(part._any-and-any~7cc)"></a><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span>&#21644;<span class="RktSym"><span class="badlink"><span class="RktValLink">any/c</span></span></span></h5><p>&#29992;&#20110;<span class="RktSym">deposit</span>&#30340;<span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span>&#21512;&#32422;&#21305;&#37197;&#20219;&#20309;&#32467;&#26524;&#65292;&#24182;&#19988;&#23427;&#21482;&#33021;&#29992;&#20110;&#19968;&#20010;&#20989;&#25968;&#21512;&#32422;&#30340;&#20540;&#22495;&#20301;&#32622;&#12290;&#20195;&#26367;&#19978;&#38754;&#30340;<span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span>&#65292;&#25105;&#20204;&#21487;&#20197;&#20351;&#29992;&#26356;&#20855;&#20307;&#30340;&#21512;&#32422;<span class="RktSym"><span class="badlink"><span class="RktValLink">void?</span></span></span>&#65292;&#23427;&#34920;&#31034;&#20989;&#25968;&#24635;&#20250;&#36820;&#22238;<span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">void</span></span></span><span class="RktPn">)</span>&#20540;&#12290;&#28982;&#32780;&#65292;<span class="RktSym"><span class="badlink"><span class="RktValLink">void?</span></span></span>&#21512;&#32422;&#20250;&#35201;&#27714;&#21512;&#32422;&#30417;&#35270;&#31995;&#32479;&#27599;&#27425;&#22312;&#20989;&#25968;&#34987;&#35843;&#29992;&#26102;&#21435;&#26816;&#26597;&#36825;&#20010;&#36820;&#22238;&#20540;&#65292;&#21363;&#20351;&#8220;&#23458;&#25143;&#31471;&#8221;&#27169;&#22359;&#19981;&#33021;&#24456;&#22909;&#29992;&#36825;&#20010;&#20540;&#24037;&#20316;&#12290;&#30456;&#21453;&#65292;<span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span>&#21578;&#35785;&#30417;&#35270;&#31995;&#32479;<span style="font-style: italic">&#19981;</span>&#26816;&#26597;&#36825;&#20010;&#36820;&#22238;&#20540;&#65292;&#23427;&#21578;&#35785;&#19968;&#20010;&#28508;&#22312;&#23458;&#25143;&#31471;&#36825;&#20010;&#8220;&#26381;&#21153;&#22120;&#8221;&#27169;&#22359;&#23545;&#36825;&#20010;&#20989;&#25968;&#30340;&#36820;&#22238;&#20540;<span style="font-style: italic">&#19981;&#20316;&#20219;&#20309;&#25215;&#35834;</span>&#65292;&#29978;&#33267;&#19981;&#31649;&#23427;&#26159;&#19968;&#20010;&#21333;&#29420;&#30340;&#20540;&#25110;&#22810;&#20010;&#20540;&#12290;</p><p><span class="RktSym"><span class="badlink"><span class="RktValLink">any/c</span></span></span>&#21512;&#32422;&#31867;&#20284;&#20110;<span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span>&#65292;&#22312;&#37027;&#37324;&#23427;&#23545;&#19968;&#20010;&#20540;&#19981;&#20570;&#35201;&#27714;&#12290;&#19981;&#20687;<span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span>&#65292;<span class="RktSym"><span class="badlink"><span class="RktValLink">any/c</span></span></span>&#34920;&#31034;&#19968;&#20010;&#21333;&#20010;&#20540;&#65292;&#24182;&#19988;&#23427;&#36866;&#21512;&#29992;&#20316;&#19968;&#20010;&#21442;&#25968;&#21512;&#32422;&#12290;&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">any/c</span></span></span>&#20316;&#20026;&#19968;&#20010;&#20540;&#22495;&#21512;&#32422;&#24378;&#36843;&#19968;&#20010;&#23545;&#36825;&#20010;&#20989;&#25968;&#20135;&#29983;&#19968;&#20010;&#21333;&#20010;&#20540;&#30340;&#26816;&#26597;&#12290;&#23601;&#20687;&#36825;&#26679;&#65292;</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span></p></blockquote><p>&#25551;&#36848;&#19968;&#20010;&#25509;&#21463;&#19968;&#20010;&#25972;&#25968;&#24182;&#36820;&#22238;&#20219;&#24847;&#25968;&#20540;&#30340;&#20989;&#25968;&#65292;&#28982;&#32780;</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any/c</span></span></span><span class="RktPn">)</span></p></blockquote><p>&#25551;&#36848;&#25509;&#21463;&#19968;&#20010;&#25972;&#25968;&#24182;&#29983;&#25104;&#19968;&#20010;&#21333;&#20010;&#32467;&#26524;&#65288;&#20294;&#23545;&#32467;&#26524;&#27809;&#26377;&#26356;&#22810;&#35828;&#26126;&#65289;&#30340;&#19968;&#20010;&#20989;&#25968;&#12290;&#20197;&#19979;&#20989;&#25968;</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">f</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">values</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">+</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktVal">1</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote><p>&#21305;&#37197;<span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="stt"> </span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="stt"> </span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span>&#65292;&#20294;&#19981;&#21305;&#37197;<span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="stt"> </span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="stt"> </span><span class="RktSym"><span class="badlink"><span class="RktValLink">any/c</span></span></span><span class="RktPn">)</span>&#12290;</p><p>&#24403;&#23545;&#25215;&#35834;&#26469;&#33258;&#19968;&#20010;&#20989;&#25968;&#30340;&#19968;&#20010;&#21333;&#20010;&#32467;&#26524;&#29305;&#21035;&#37325;&#35201;&#26102;&#65292;&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">any/c</span></span></span>&#20316;&#20026;&#19968;&#20010;&#32467;&#26524;&#21512;&#32422;&#12290;&#24403;&#20320;&#24076;&#26395;&#23545;&#19968;&#20010;&#20989;&#25968;&#30340;&#32467;&#26524;&#23613;&#21487;&#33021;&#23569;&#22320;&#25215;&#35834;&#65288;&#24182;&#23613;&#21487;&#33021;&#23569;&#22320;&#26816;&#26597;&#65289;&#26102;&#65292;&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">any/c</span></span></span>&#12290;</p><h5>7.2.4<tt>&nbsp;</tt><a name="(part._contracts-own)"></a>&#36816;&#36716;&#20320;&#33258;&#24049;&#30340;&#21512;&#32422;</h5><p><span class="RktSym">deposit</span>&#20989;&#25968;&#23558;&#32473;&#23450;&#30340;&#25968;&#20540;&#28155;&#21152;&#21040;<span class="RktSym">amount</span>&#20013;&#12290;&#24403;&#35813;&#20989;&#25968;&#30340;&#21512;&#32422;&#38459;&#27490;&#23458;&#25143;&#31471;&#23558;&#23427;&#24212;&#29992;&#21040;&#38750;&#25968;&#20540;&#26102;&#65292;&#36825;&#20010;&#21512;&#32422;&#20173;&#28982;&#20801;&#35768;&#23427;&#20204;&#25226;&#36825;&#20010;&#20989;&#25968;&#24212;&#29992;&#21040;&#22797;&#25968;&#12289;&#36127;&#25968;&#25110;&#19981;&#31934;&#30830;&#30340;&#25968;&#23383;&#20013;&#65292;&#20294;&#27809;&#26377;&#19968;&#20010;&#33021;&#21512;&#29702;&#22320;&#34920;&#31034;&#38065;&#30340;&#37329;&#39069;&#12290;</p><p>&#21512;&#32422;&#31995;&#32479;&#20801;&#35768;&#31243;&#24207;&#21592;&#23450;&#20041;&#20182;&#20204;&#33258;&#24049;&#30340;&#21512;&#32422;&#20316;&#20026;&#20989;&#25968;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><font class="badlink"><span class="RktModLink"><span class="RktMod">#lang</span></span></font><span class="hspace">&nbsp;</span><font class="badlink"><span class="RktModLink"><span class="RktSym">racket</span></span></font></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">amount?</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">and</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">exact?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">&gt;=</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">provide</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">contract-out</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#19968;&#20010;&#37329;&#39069;&#26159;&#19968;&#20010;&#32654;&#20998;&#30340;&#33258;&#28982;&#25968;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#26159;&#32473;&#23450;&#30340;&#25968;&#23383;&#30340;&#19968;&#20010;amount?</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount?</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">amount?</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any/c</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">boolean?</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">balance</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount?</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">+</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">balance</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">amount</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#36825;&#20010;&#27169;&#22359;&#23450;&#20041;&#20102;&#19968;&#20010;<span class="RktSym">amount?</span>&#20989;&#25968;&#24182;&#22312;<span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span>&#21512;&#32422;&#20869;&#20351;&#29992;&#23427;&#20316;&#20026;&#19968;&#20010;&#21512;&#32422;&#12290;&#24403;&#19968;&#20010;&#23458;&#25143;&#31471;&#29992;<span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="stt"> </span><span class="RktSym">amount?</span><span class="stt"> </span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span>&#35843;&#29992;<span class="RktSym">deposit</span>&#20989;&#25968;&#20316;&#20026;&#36755;&#20986;&#26102;&#65292;&#23427;&#24517;&#39035;&#25552;&#20379;&#19968;&#20010;&#31934;&#30830;&#30340;&#12289;&#38750;&#36127;&#30340;&#25972;&#25968;&#65292;&#21542;&#21017;<span class="RktSym">amount?</span>&#20989;&#25968;&#24212;&#29992;&#21040;&#21442;&#25968;&#23558;&#36820;&#22238;<span class="RktVal">#f</span>&#65292;&#36825;&#23558;&#23548;&#33268;&#21512;&#32422;&#30417;&#35270;&#31995;&#32479;&#24402;&#21646;&#20110;&#23458;&#25143;&#31471;&#12290;&#31867;&#20284;&#22320;&#65292;&#26381;&#21153;&#22120;&#27169;&#22359;&#24517;&#39035;&#25552;&#20379;&#19968;&#20010;&#31934;&#30830;&#30340;&#12289;&#38750;&#36127;&#30340;&#25972;&#25968;&#20316;&#20026;<span class="RktSym">balance</span>&#30340;&#32467;&#26524;&#20197;&#20445;&#25345;&#26080;&#21487;&#24402;&#21646;&#12290;</p><p>&#24403;&#28982;&#65292;&#23558;&#19968;&#20010;&#36890;&#20449;&#36890;&#36947;&#38480;&#21046;&#20026;&#23458;&#25143;&#31471;&#19981;&#26126;&#30333;&#30340;&#20540;&#26159;&#27809;&#26377;&#24847;&#20041;&#30340;&#12290;&#22240;&#27492;&#65292;&#36825;&#20010;&#27169;&#22359;&#20063;&#36755;&#20986;<span class="RktSym">amount?</span>&#21028;&#26029;&#26412;&#36523;&#65292;&#29992;&#19968;&#20010;&#21512;&#32422;&#34920;&#31034;&#23427;&#25509;&#21463;&#19968;&#20010;&#20219;&#24847;&#20540;&#24182;&#36820;&#22238;&#19968;&#20010;&#24067;&#23572;&#20540;&#12290;</p><p>&#22312;&#36825;&#31181;&#24773;&#20917;&#19979;&#65292;&#25105;&#20204;&#20063;&#21487;&#20197;&#20351;&#29992;<span class="RktSym"><span class="badlink"><span class="RktValLink">natural-number/c</span></span></span>&#20195;&#26367;<span class="RktSym">amount?</span>&#65292;&#22240;&#20026;&#23427;&#24688;&#24688;&#24847;&#21619;&#30528;&#30456;&#21516;&#30340;&#26816;&#26597;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">provide</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">contract-out</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">natural-number/c</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">balance</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">natural-number/c</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#25509;&#21463;&#19968;&#20010;&#21442;&#25968;&#30340;&#27599;&#19968;&#20010;&#20989;&#25968;&#21487;&#20197;&#24403;&#20316;&#19968;&#20010;&#21028;&#26029;&#20174;&#32780;&#34987;&#29992;&#20316;&#19968;&#20010;&#21512;&#32422;&#12290;&#28982;&#32780;&#65292;&#20026;&#20102;&#32467;&#21512;&#29616;&#26377;&#30340;&#23545;&#19968;&#20010;&#26032;&#21442;&#25968;&#30340;&#26816;&#26597;&#65292;&#21512;&#32422;&#36830;&#25509;&#31526;&#20687;<span class="RktSym"><span class="badlink"><span class="RktValLink">and/c</span></span></span>&#25110;<span class="RktSym"><span class="badlink"><span class="RktValLink">or/c</span></span></span>&#24448;&#24448;&#26159;&#26377;&#29992;&#30340;&#12290;&#20363;&#22914;&#65292;&#36825;&#37324;&#36824;&#26377;&#21478;&#19968;&#31181;&#36884;&#24452;&#21435;&#32534;&#20889;&#19978;&#36848;&#21512;&#32422;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount/c</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">and/c</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">exact?</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">or/c</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">positive?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">zero?</span></span></span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">provide</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">contract-out</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount/c</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">balance</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">amount/c</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#20854;&#23427;&#20540;&#20063;&#20316;&#20026;&#21512;&#32422;&#25552;&#20379;&#21452;&#37325;&#20219;&#21153;&#12290;&#20363;&#22914;&#65292;&#22914;&#26524;&#19968;&#20010;&#20989;&#25968;&#25509;&#21463;&#19968;&#20010;&#25968;&#20540;&#25110;<span class="RktVal">#f</span>&#65292;<span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">or/c</span></span></span><span class="stt"> </span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="stt"> </span><span class="RktVal">#f</span><span class="RktPn">)</span>&#23601;&#22815;&#20102;&#12290;&#21516;&#26679;&#65292;<span class="RktSym">amount/c</span>&#21512;&#32422;&#20063;&#35768;&#24050;&#32463;&#29992;&#19968;&#20010;<span class="RktVal">0</span>&#20195;&#26367;<span class="RktSym"><span class="badlink"><span class="RktValLink">zero?</span></span></span>&#26469;&#32534;&#20889;&#12290;&#22914;&#26524;&#20320;&#20351;&#29992;&#19968;&#20010;&#27491;&#21017;&#34920;&#36798;&#24335;&#20316;&#20026;&#19968;&#20010;&#21512;&#32422;&#65292;&#35813;&#21512;&#32422;&#25509;&#21463;&#19982;&#27491;&#21017;&#34920;&#36798;&#24335;&#21305;&#37197;&#30340;&#23383;&#31526;&#20018;&#21644;&#23383;&#33410;&#23383;&#31526;&#20018;&#12290;</p><p>&#24403;&#28982;&#65292;&#20320;&#21487;&#20197;&#29992;&#36830;&#25509;&#31526;&#20687;<span class="RktSym"><span class="badlink"><span class="RktValLink">and/c</span></span></span>&#28151;&#21512;&#20320;&#33258;&#24049;&#30340;&#21512;&#32422;&#25191;&#34892;&#20989;&#25968;&#12290;&#36825;&#37324;&#26377;&#19968;&#20010;&#29992;&#20110;&#21019;&#24314;&#26469;&#33258;&#20110;&#38134;&#34892;&#35760;&#24405;&#30340;&#23383;&#31526;&#20018;&#30340;&#27169;&#22359;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><font class="badlink"><span class="RktModLink"><span class="RktMod">#lang</span></span></font><span class="hspace">&nbsp;</span><font class="badlink"><span class="RktModLink"><span class="RktSym">racket</span></span></font></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">has-decimal?</span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">L</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string-length</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">and</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">&gt;=</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">L</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">char=?</span></span></span><span class="hspace">&nbsp;</span><span class="RktVal">#\.</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string-ref</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">L</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">provide</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">contract-out</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#36716;&#25442;&#19968;&#20010;&#38543;&#26426;&#25968;&#20026;&#19968;&#20010;&#23383;&#31526;&#20018;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">format-number</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string?</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#29992;&#19968;&#20010;&#21313;&#36827;&#21046;&#28857;&#36716;&#25442;&#19968;&#20010;&#37329;&#39069;&#20026;&#19968;&#20010;&#23383;&#31526;&#20018;&#65292;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#23601;&#20687;&#22312;&#32654;&#22269;&#36135;&#24065;&#30340;&#19968;&#20010;&#37329;&#39069;&#37027;&#26679;&#12290;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">format-nat</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">natural-number/c</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">and/c</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">has-decimal?</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#36755;&#20986;&#20989;&#25968;<span class="RktSym">format-number</span>&#30340;&#21512;&#32422;&#25351;&#23450;&#35813;&#20989;&#25968;&#25509;&#21463;&#19968;&#20010;&#25968;&#20540;&#24182;&#29983;&#25104;&#19968;&#20010;&#23383;&#31526;&#20018;&#12290;&#36825;&#20010;&#36755;&#20986;&#20989;&#25968;<span class="RktSym">format-nat</span>&#30340;&#21512;&#32422;&#27604;<span class="RktSym">format-number</span>&#30340;&#20854;&#20013;&#20043;&#19968;&#26356;&#26377;&#36259;&#12290;&#23427;&#21482;&#25509;&#21463;&#33258;&#28982;&#25968;&#12290;&#23427;&#30340;&#20540;&#22495;&#21512;&#32422;&#25215;&#35834;&#22312;&#21491;&#36793;&#30340;&#31532;&#19977;&#20010;&#20301;&#32622;&#24102;&#26377;&#19968;&#20010;<span class="RktInBG"><span class="hspace"></span><span class="RktIn">.</span><span class="hspace"></span></span>&#30340;&#23383;&#31526;&#20018;&#12290;</p><p>&#22914;&#26524;&#25105;&#20204;&#24076;&#26395;&#21152;&#24378;<span class="RktSym">format-nat</span>&#30340;&#20540;&#22495;&#21512;&#32422;&#30340;&#25215;&#35834;&#65292;&#20197;&#20415;&#23427;&#21482;&#25509;&#21463;&#24102;&#25968;&#23383;&#21644;&#19968;&#20010;&#28857;&#30340;&#23383;&#31526;&#20018;&#65292;&#25105;&#20204;&#21487;&#20197;&#36825;&#26679;&#32534;&#20889;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><font class="badlink"><span class="RktModLink"><span class="RktMod">#lang</span></span></font><span class="hspace">&nbsp;</span><font class="badlink"><span class="RktModLink"><span class="RktSym">racket</span></span></font></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">digit-char?</span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">member</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">(</span><span class="RktVal">#\1</span><span class="hspace">&nbsp;</span><span class="RktVal">#\2</span><span class="hspace">&nbsp;</span><span class="RktVal">#\3</span><span class="hspace">&nbsp;</span><span class="RktVal">#\4</span><span class="hspace">&nbsp;</span><span class="RktVal">#\5</span><span class="hspace">&nbsp;</span><span class="RktVal">#\6</span><span class="hspace">&nbsp;</span><span class="RktVal">#\7</span><span class="hspace">&nbsp;</span><span class="RktVal">#\8</span><span class="hspace">&nbsp;</span><span class="RktVal">#\9</span><span class="hspace">&nbsp;</span><span class="RktVal">#\0</span><span class="RktVal">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">has-decimal?</span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">L</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string-length</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">and</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">&gt;=</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">L</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">char=?</span></span></span><span class="hspace">&nbsp;</span><span class="RktVal">#\.</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string-ref</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">L</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">is-decimal-string?</span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">L</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string-length</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">and</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">has-decimal?</span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">andmap</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">digit-char?</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string-&gt;list</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">substring</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">L</span><span class="hspace">&nbsp;</span><span class="RktVal">3</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">andmap</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">digit-char?</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string-&gt;list</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">substring</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">str</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">L</span><span class="hspace">&nbsp;</span><span class="RktVal">2</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym">L</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktSym">....</span></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">provide</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">contract-out</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">....</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#36716;&#25442;&#32654;&#20998;&#30340;&#19968;&#20010;&#37329;&#39069;&#65288;&#33258;&#28982;&#25968;&#65289;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#25104;&#20026;&#19968;&#20010;&#22522;&#20110;&#32654;&#20803;&#30340;&#23383;&#31526;&#20018;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">format-nat</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">natural-number/c</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">and/c</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string?</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym">is-decimal-string?</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><p>&#21478;&#22806;&#65292;&#22312;&#36825;&#31181;&#24773;&#20917;&#19979;&#65292;&#25105;&#20204;&#21487;&#20197;&#20351;&#29992;&#19968;&#20010;&#27491;&#21017;&#34920;&#36798;&#24335;&#20316;&#20026;&#19968;&#20010;&#21512;&#32422;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><font class="badlink"><span class="RktModLink"><span class="RktMod">#lang</span></span></font><span class="hspace">&nbsp;</span><font class="badlink"><span class="RktModLink"><span class="RktSym">racket</span></span></font></td></tr><tr><td><span class="hspace">&nbsp;</span></td></tr><tr><td><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">provide</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">contract-out</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktSym">....</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#36716;&#25442;&#32654;&#20998;&#30340;&#19968;&#20010;&#25968;&#37327;&#65288;&#33258;&#28982;&#25968;&#65289;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktCmt">;</span><span class="RktCmt">&nbsp;</span><span class="RktCmt">&#25104;&#20026;&#19968;&#20010;&#22522;&#20110;&#32654;&#20803;&#30340;&#23383;&#31526;&#20018;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">format-nat</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">natural-number/c</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">and/c</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">string?</span></span></span><span class="hspace">&nbsp;</span><span class="RktVal">#rx"[0-9]*\\.[0-9][0-9]"</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></blockquote><h5>7.2.5<tt>&nbsp;</tt><a name="(part._contracts-.Contracts-on-.Higher-order-.Functions)"></a>&#39640;&#38454;&#20989;&#25968;&#30340;&#21512;&#32422;</h5><p>&#20989;&#25968;&#21512;&#32422;&#19981;&#20165;&#20165;&#23616;&#38480;&#20110;&#22312;&#20854;&#23450;&#20041;&#22495;&#25110;&#20540;&#22495;&#19978;&#30340;&#31616;&#21333;&#21028;&#26029;&#12290;&#36824;&#21253;&#25324;&#23427;&#20204;&#33258;&#24049;&#30340;&#20989;&#25968;&#21512;&#32422;&#65292;&#33021;&#22815;&#34987;&#29992;&#20316;&#21442;&#25968;&#21450;&#19968;&#20010;&#20989;&#25968;&#32467;&#26524;&#12290;</p><p>&#20363;&#22914;&#65306;</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="RktPn">)</span><span class="RktPn">)</span></p></blockquote><p>&#26159;&#25551;&#36848;&#19968;&#20010;&#26607;&#37324;&#20989;&#25968;&#30340;&#19968;&#20010;&#21512;&#32422;&#12290;&#23427;&#21305;&#37197;&#25509;&#21463;&#19968;&#20010;&#21442;&#25968;&#30340;&#20989;&#25968;&#24182;&#25509;&#30528;&#22312;&#36820;&#22238;&#21478;&#19968;&#20010;&#25509;&#21463;&#19968;&#20010;&#21069;&#38754;&#30340;&#31532;&#20108;&#20010;&#21442;&#25968;&#65292;&#26368;&#21518;&#36820;&#22238;&#19968;&#20010;&#25972;&#25968;&#12290;&#22914;&#26524;&#19968;&#20010;&#26381;&#21153;&#22120;&#29992;&#36825;&#20010;&#21512;&#32422;&#36755;&#20986;&#19968;&#20010;&#20989;&#25968;<span class="RktSym">make-adder</span>&#65292;&#24182;&#19988;&#22914;&#26524;<span class="RktSym">make-adder</span>&#36820;&#22238;&#19968;&#20010;&#20989;&#25968;&#22806;&#36824;&#36820;&#22238;&#19968;&#20010;&#20540;&#65292;&#37027;&#20040;&#36825;&#20010;&#26381;&#21153;&#22120;&#24212;&#34987;&#24402;&#21646;&#12290;&#22914;&#26524;<span class="RktSym">make-adder</span>&#30830;&#23454;&#36820;&#22238;&#19968;&#20010;&#20989;&#25968;&#65292;&#20294;&#36825;&#20010;&#36820;&#22238;&#20989;&#25968;&#34987;&#24212;&#29992;&#20110;&#19968;&#20010;&#25972;&#25968;&#22806;&#36824;&#26377;&#19968;&#20010;&#20540;&#65292;&#21017;&#23458;&#25143;&#31471;&#24212;&#34987;&#24402;&#21646;&#12290;</p><p>&#21516;&#26679;&#65292;&#21512;&#32422;</p><blockquote class="SCodeFlow"><p><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="RktPn">)</span></p></blockquote><p>&#25551;&#36848;&#25509;&#21463;&#20854;&#23427;&#20989;&#25968;&#20316;&#20026;&#20854;&#36755;&#20837;&#30340;&#20989;&#25968;&#12290;&#22914;&#26524;&#19968;&#20010;&#26381;&#21153;&#22120;&#29992;&#36825;&#20010;&#21512;&#32422;&#36755;&#20986;&#19968;&#20010;&#20989;&#25968;<span class="RktSym">twice</span>&#24182;&#19988;<span class="RktSym">twice</span>&#34987;&#24212;&#29992;&#32473;&#19968;&#20010;&#24102;&#19968;&#20010;&#21442;&#25968;&#30340;&#20989;&#25968;&#22806;&#36824;&#32473;&#19968;&#20010;&#20540;&#65292;&#37027;&#20040;&#23458;&#25143;&#31471;&#24212;&#34987;&#24402;&#21646;&#12290;&#22914;&#26524;<span class="RktSym">twice</span>&#34987;&#24212;&#29992;&#32473;&#19968;&#20010;&#24102;&#19968;&#20010;&#21442;&#25968;&#30340;&#20989;&#25968;&#24182;&#19988;<span class="RktSym">twice</span>&#23545;&#19968;&#20010;&#25972;&#25968;&#35843;&#29992;&#36825;&#20010;&#32473;&#23450;&#30340;&#20989;&#25968;&#22806;&#36824;&#23545;&#19968;&#20010;&#20540;&#65292;&#37027;&#20040;&#26381;&#21153;&#22120;&#24212;&#34987;&#24402;&#21646;&#12290;</p><h5>7.2.6<tt>&nbsp;</tt><a name="(part._contracts-flat-named-contracts)"></a>&#24102;&#8221;???&#8220;&#30340;&#21512;&#32422;&#20449;&#24687;</h5><p>&#20320;&#32534;&#20889;&#20102;&#20320;&#30340;&#27169;&#22359;&#12290;&#20320;&#28155;&#21152;&#20102;&#21512;&#32422;&#12290;&#20320;&#23558;&#23427;&#20204;&#25918;&#20837;&#25509;&#21475;&#20197;&#20415;&#23458;&#25143;&#31471;&#31243;&#24207;&#21592;&#25317;&#26377;&#26469;&#33258;&#25509;&#21475;&#30340;&#25152;&#26377;&#20449;&#24687;&#12290;&#36825;&#26159;&#19968;&#38376;&#33402;&#26415;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">module</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">bank-server</span><span class="hspace">&nbsp;</span><span class="RktSym">racket</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">provide</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">contract-out</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">&#955;</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">and</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">&gt;=</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">total</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">total</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">+</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">total</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote><p>&#20960;&#20010;&#23458;&#25143;&#31471;&#20351;&#29992;&#20102;&#20320;&#30340;&#27169;&#22359;&#12290;&#20854;&#20182;&#20154;&#36716;&#32780;&#20351;&#29992;&#20102;&#20182;&#20204;&#30340;&#27169;&#22359;&#12290;&#31361;&#28982;&#20182;&#20204;&#20013;&#30340;&#19968;&#20010;&#30475;&#21040;&#20102;&#36825;&#20010;&#38169;&#35823;&#28040;&#24687;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">require</span></span></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">bank-server</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktVal"><span class="nobreak">-1</span>0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">deposit: contract violation</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">expected: ???</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">given: -10</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: the 1st argument of</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">(-&gt; ??? any)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">contract from: bank-server</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">blaming: top-level</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">(assuming the contract is correct)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">at: eval:2.0</span></p></td></tr></table></blockquote><p><span class="RktErr">???</span>&#22312;&#37027;&#37324;&#20195;&#34920;&#20160;&#20040;&#65311;&#22914;&#26524;&#25105;&#20204;&#26377;&#36825;&#26679;&#19968;&#20010;&#25968;&#25454;&#31867;&#22411;&#30340;&#21517;&#23383;&#65292;&#23601;&#20687;&#25105;&#20204;&#26377;&#23383;&#31526;&#20018;&#12289;&#25968;&#23383;&#31561;&#31561;&#65292;&#37027;&#19981;&#26159;&#24456;&#22909;&#21527;&#65311;</p><p>&#38024;&#23545;&#36825;&#31181;&#24773;&#20917;&#65292;Racket&#25552;&#20379;&#20102;<a name="(tech._~e6~89~81~e5~b9~b3~e5~91~bd~e5~90~8d~e5~90~88~e7~ba~a6~ef~bc~88flat._named._contract~ef~bc~89)"></a><span style="font-style: italic">&#25153;&#24179;&#21629;&#21517;&#21512;&#32422;&#65288;flat named contract&#65289;</span>&#12290;&#22312;&#36825;&#19968;&#26415;&#35821;&#20013;&#20351;&#29992;&#8220;&#21512;&#32422;&#8221;&#34920;&#26126;&#21512;&#32422;&#26159;&#31532;&#19968;&#31867;&#20540;&#12290;&#36825;&#20010;&#8220;&#25153;&#24179;&#65288;flat&#65289;&#8221;&#24847;&#21619;&#30528;&#25968;&#25454;&#30340;&#38598;&#21512;&#26159;&#20869;&#24314;&#30340;&#25968;&#25454;&#21407;&#23376;&#31867;&#30340;&#19968;&#20010;&#23376;&#38598;&#65307;&#23427;&#20204;&#30001;&#19968;&#20010;&#25509;&#21463;&#25152;&#26377;Racket&#20540;&#24182;&#20135;&#29983;&#19968;&#20010;&#24067;&#23572;&#20540;&#30340;&#21028;&#26029;&#26469;&#25551;&#36848;&#12290;&#36825;&#20010;&#8220;&#21629;&#21517;&#65288;named&#65289;&#8221;&#37096;&#20998;&#34920;&#31034;&#25105;&#20204;&#24819;&#35201;&#20570;&#30340;&#20107;&#24773;&#65292;&#23427;&#23558;&#21435;&#21629;&#21517;&#36825;&#20010;&#21512;&#32422;&#20197;&#20415;&#38169;&#35823;&#28040;&#24687;&#21464;&#24471;&#26126;&#30333;&#26131;&#25026;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">module</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">improved-bank-server</span><span class="hspace">&nbsp;</span><span class="RktSym">racket</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">provide</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">contract-out</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">[</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">-&gt;</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">flat-named-contract</span></span></span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktVal">'</span><span class="RktVal">amount</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">&#955;</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">x</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">and</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">number?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">integer?</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">&gt;=</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">x</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span><span class="RktSym"><span class="badlink"><span class="RktValLink">any</span></span></span><span class="RktPn">)</span><span class="RktPn">]</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">total</span><span class="hspace">&nbsp;</span><span class="RktVal">0</span><span class="RktPn">)</span></td></tr><tr><td><span class="hspace">&nbsp;&nbsp;</span><span class="hspace">&nbsp;&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">define</span></span></span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="RktPn">)</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">set!</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">total</span><span class="hspace">&nbsp;</span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">+</span></span></span><span class="hspace">&nbsp;</span><span class="RktSym">a</span><span class="hspace">&nbsp;</span><span class="RktSym">total</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span><span class="RktPn">)</span></td></tr></table></td></tr></table></blockquote><p>&#29992;&#36825;&#20010;&#23567;&#23567;&#30340;&#26356;&#25913;&#65292;&#36825;&#20010;&#38169;&#35823;&#28040;&#24687;&#23601;&#21464;&#24471;&#30456;&#24403;&#26131;&#35835;&#65306;</p><blockquote class="SCodeFlow"><table cellspacing="0" cellpadding="0" class="RktBlk"><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym"><span class="badlink"><span class="RktValLink">require</span></span></span><span class="hspace">&nbsp;</span><span class="RktVal">'</span><span class="RktVal">improved-bank-server</span><span class="RktPn">)</span></td></tr><tr><td><span class="stt">&gt; </span><span class="RktPn">(</span><span class="RktSym">deposit</span><span class="hspace">&nbsp;</span><span class="RktVal"><span class="nobreak">-1</span>0</span><span class="RktPn">)</span></td></tr><tr><td><p><span class="RktErr">deposit: contract violation</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">expected: amount</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">given: -10</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">in: the 1st argument of</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">(-&gt; amount any)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">contract from: improved-bank-server</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">blaming: top-level</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;</span><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">(assuming the contract is correct)</span></p></td></tr><tr><td><p><span class="RktErr"></span><span class="hspace">&nbsp;&nbsp;</span><span class="RktErr">at: eval:5.0</span></p></td></tr></table></blockquote><h5>7.2.7<tt>&nbsp;</tt><a name="(part._contracts-dissecting-contract-errors)"></a>&#35299;&#26512;&#19968;&#20010;&#21512;&#32422;&#38169;&#35823;&#20449;&#24687;</h5><p>&#19968;&#33324;&#26469;&#35828;&#65292;&#27599;&#20010;&#21512;&#32422;&#38169;&#35823;&#20449;&#24687;&#30001;&#20845;&#37096;&#20998;&#32452;&#25104;&#65306;</p><ul><li><p><div class="SIntrapara">&#19968;&#20010;&#29992;&#21512;&#32422;&#20851;&#32852;&#30340;&#20989;&#25968;&#25110;&#26041;&#27861;&#30340;&#21517;&#31216;&#12290;&#32780;&#19988;&#36825;&#20010;&#30701;&#35821;&#8220;&#21512;&#32422;&#36829;&#21453;&#8221;&#25110;&#8220;&#36829;&#21453;&#21512;&#32422;&#8221;&#21462;&#20915;&#20110;&#26159;&#21542;&#36825;&#20010;&#21512;&#32422;&#34987;&#23458;&#25143;&#31471;&#25110;&#26381;&#21153;&#22120;&#36829;&#21453;&#65307;&#20363;&#22914;&#22312;&#21069;&#38754;&#30340;&#31034;&#20363;&#20013;&#65306;</div><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p class="RktErr">deposit: contract violation</p></td></tr></table></div><div class="SIntrapara">&#65307;</div></p></li><li><p><div class="SIntrapara">&#19968;&#20010;&#34987;&#36829;&#21453;&#30340;&#21512;&#32422;&#30340;&#20934;&#30830;&#26041;&#38754;&#30340;&#25551;&#36848;&#65292;</div><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p class="RktErr">  expected: amount</p></td></tr><tr><td><p class="RktErr">  given: -10</p></td></tr></table></div><div class="SIntrapara">&#65307;</div></p></li><li><p><div class="SIntrapara">&#36825;&#20010;&#23436;&#25972;&#30340;&#21512;&#32422;&#21152;&#19978;&#19968;&#20010;&#36335;&#24452;&#26174;&#31034;&#21738;&#20010;&#26041;&#38754;&#34987;&#36829;&#21453;&#65292;</div><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p class="RktErr">  in: the 1st argument of</p></td></tr><tr><td><p class="RktErr">      (-&gt; amount any)</p></td></tr></table></div><div class="SIntrapara">&#65307;</div></p></li><li><p><div class="SIntrapara">&#21512;&#32422;&#34987;&#25918;&#32622;&#30340;&#36825;&#20010;&#27169;&#22359;&#65288;&#25110;&#32773;&#26356;&#24191;&#27867;&#22320;&#35828;&#65292;&#21512;&#21516;&#25152;&#35268;&#23450;&#30340;&#36793;&#30028;&#65289;&#65292;</div><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p class="RktErr">  contract from: improved-bank-server</p></td></tr></table></div><div class="SIntrapara">&#65307;</div></p></li><li><p><div class="SIntrapara">&#21738;&#20010;&#24212;&#34987;&#24402;&#21646;&#65292;</div><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p class="RktErr">  blaming: top-level</p></td></tr><tr><td><p class="RktErr">   (assuming the contract is correct)</p></td></tr></table></div><div class="SIntrapara">&#65307;</div></p></li><li><p><div class="SIntrapara">&#20197;&#21450;&#36825;&#20010;&#21512;&#32422;&#20986;&#29616;&#30340;&#28304;&#31243;&#24207;&#20301;&#32622;&#12290; </div><div class="SIntrapara"><table cellspacing="0" cellpadding="0"><tr><td><p class="RktErr">  at: eval:5.0</p></td></tr></table></div><div class="SIntrapara">&#12290;</div></p></li></ul><div class="navsetbottom"><span class="navleft"><div class="nosearchform"></div>&nbsp;&nbsp;</span><span class="navright">&nbsp;&nbsp;<a href="contract-boundaries.html" title="backward to &quot;7.1 合约和边界&quot;" data-pltdoc="x">&larr; prev</a>&nbsp;&nbsp;<a href="contracts.html" title="up to &quot;7 合约&quot;" data-pltdoc="x">up</a>&nbsp;&nbsp;<a href="contracts-general-functions.html" title="forward to &quot;7.3 一般功能合约&quot;" data-pltdoc="x">next &rarr;</a></span>&nbsp;</div></div></div><div id="contextindicator">&nbsp;</div></body></html>